var config = require('./webim.config');
var $ = require('jquery');
var Webim = require('./core/im');
var util = require('imutil');
var Backbone = require('backbone');
var bus = require('bus');
var logger = require('logger');
var Global = require('global');
var i18n = require('./i18n');

// 设置日志工具启动
logger.enable(!!config.debug);

// 防止锁屏后，超时进入页面报错引起代码停止
Global.onerror = function(errorMessage, scriptURI, lineNumber, columnNumber, errorObj){
	logger.log(arguments);
};

// 语言版本
config.locale = 'en';

// tm 代码根目录
config.rootPath = '{{=root}}';

// 当前访问的站点
config.site = /^m\.made-in-china\.com$/.test(location.hostname) ? 'MOBILE' : 'PC';

// token 获取地址
config.tokenUrl = config.equipment === 'TOUCH_WEB'
	? 'http://m.made-in-china.com/webtm/getauth/'
	: 'http://membercenter.made-in-china.com/tm.do?xcase=token4TMWeb&callback=?';

// 记录原始路径地址，用于url跳回时隐藏界面
config.originalHash = (location.hash || "").replace(/^#/, '');

if(!Global.MaiTong_Touch){
	Global.MaiTong_Touch = {};
}

Global.MaiTong_Touch.IMClient = Webim;